home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlib.zip / BCOPY.C < prev    next >
Text File  |  1993-01-04  |  1KB  |  45 lines

  1.  
  2. /*  File   : bcopy.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 23 April 1984
  5.     Defines: bcopy()
  6.  
  7.     bcopy(src, dst, len) moves exactly "len" bytes from the source "src"
  8.     to the destination "dst".  It does not check for NUL characters as
  9.     strncpy() and strnmov() do.  Thus if your C compiler doesn't support
  10.     structure assignment, you can simulate it with
  11.         bcopy(&from, &to, sizeof from);
  12.     BEWARE: the first two arguments are the other way around from almost
  13.     everything else.   I'm sorry about that, but that's the way it is in
  14.     the 4.2bsd manual, though they list it as a bug.  For a version with
  15.     the arguments the right way around, use bmove().
  16.     No value is returned.
  17.  
  18.     Note: the "b" routines are there to exploit certain VAX order codes,
  19.     but the MOVC3 instruction will only move 65535 characters.   The asm
  20.     code is presented for your interest and amusement.
  21. */
  22.  
  23. #include "strings.h"
  24.  
  25. #if     VaxAsm
  26.  
  27. void bcopy(src, dst, len)
  28.     char *src, *dst;
  29.     int len;
  30.     {
  31.         asm("movc3 12(ap),*4(ap),*8(ap)");
  32.     }
  33.  
  34. #else  ~VaxAsm
  35.  
  36. void bcopy(src, dst, len)
  37.     register char *src, *dst;
  38.     register int len;
  39.     {
  40.         while (--len >= 0) *dst++ = *src++;
  41.     }
  42.  
  43. #endif  VaxAsm
  44.  
  45.